<template>
  <ComponentContainerProperty v-model="formData.style">
    <el-card header="全局设置" class="property-group" shadow="never">
      <el-form label-width="80px" :model="formData">
        <el-form-item label="查看全部" prop="showAllText">
          <el-input v-model="formData.showAllText" />
        </el-form-item>
      </el-form>
    </el-card>

    <el-card header="订单项" class="property-group" shadow="never">
      <el-form label-width="80px" :model="formData">
        <Draggable v-model="formData.list" :empty-item="EMPTY_USER_ORDER_ITEM_PROPERTY">
          <template #default="{ element }">
            <el-form-item label="标题" prop="title">
              <el-input v-model="element.title" />
            </el-form-item>
            <el-form-item label="图标" prop="icon">
              <UploadImg v-model="element.icon" height="80px" width="80px" />
            </el-form-item>
            <el-form-item label="链接" prop="path">
              <AppLinkInput v-model="element.path" />
            </el-form-item>
          </template>
        </Draggable>
      </el-form>
    </el-card>
  </ComponentContainerProperty>
</template>

<script setup lang="ts">
import { EMPTY_USER_ORDER_ITEM_PROPERTY, UserOrderProperty } from './config'
import { usePropertyForm } from '@/components/DiyEditor/util'

// 用户订单属性面板
defineOptions({ name: 'UserOrderProperty' })

const props = defineProps<{ modelValue: UserOrderProperty }>()
const emit = defineEmits(['update:modelValue'])
const { formData } = usePropertyForm(props.modelValue, emit)
</script>

<style scoped lang="scss"></style>
